package com.atg.atgchat.init.user.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/*
author: atg
time: 2025/1/17 11:01
*/
@AllArgsConstructor
@Getter
public enum IdempotentTypeEnum {
    UID(1, "uid"),
    MSG_ID(2, "消息id"),
    ;

    private final Integer type;
    private final String desc;

    private static Map<Integer, IdempotentTypeEnum> cache;

    static {
        cache = Arrays.stream(IdempotentTypeEnum.values()).collect(Collectors.toMap(IdempotentTypeEnum::getType, Function.identity()));
    }

    public static IdempotentTypeEnum of(Integer type) {
        return cache.get(type);
    }
}
